package org.neframework.test.model;

import com.tmsps.neframework.core.utils.ChkTools;

public class TableColumnModel {

	private String table;// 操作表
	private String column;// 列名

	private String columnType;// 数据类型
	private int columnSize;// 列大小

	private int decimalDigits;// 小数位数

	public String getAlterTypes() {
		// TODO 获取要 alter 的各种 type: 比如 列类型,是否非空,默认值
		// alter name double(8,3) not null default '0'
		String alter = columnType;
		if ("DOUBLE".equals(columnType)) {
			alter = alter + "(" + columnSize + "," + decimalDigits + ")";
		} else if ("VARCHAR".equals(columnType) || "CHAR".equals(columnType)) {
			alter = alter + "(" + columnSize + ")";
		}
		return alter;
	}

	public boolean isNull() {
		if (ChkTools.isNull(table) || ChkTools.isNull(column) || ChkTools.isNull(columnType)) {
			return true;
		}
		return false;
	}

	// ============ get / set ()=================================
	public String getTable() {
		return table;
	}

	public void setTable(String table) {
		this.table = table;
	}

	public String getColumn() {
		return column;
	}

	public void setColumn(String column) {
		this.column = column;
	}

	public String getColumnType() {
		return columnType;
	}

	public void setColumnType(String columnType) {
		this.columnType = columnType;
	}

	public int getColumnSize() {
		return columnSize;
	}

	public void setColumnSize(int columnSize) {
		this.columnSize = columnSize;
	}

	public int getDecimalDigits() {
		return decimalDigits;
	}

	public void setDecimalDigits(int decimalDigits) {
		this.decimalDigits = decimalDigits;
	}

}
